package com.dabai.applicationmanager.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.dabai.applicationmanager.shizuku.Shell;
import com.dabai.applicationmanager.shizuku.ShizukuShell;
import com.dabai.applicationmanager.utils.OtherUtils;
import com.dabai.dbutils.toast.DBToast;
import com.dabai.dbutils.utils.ShellUtils;

/**
 * Description : Other
 *
 * @author BAI
 */
public class StopAppActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();

        String packageName = intent.getStringExtra("packageName");
        String name = intent.getStringExtra("name");

        switch (OtherUtils.getImplementWay(this)) {
            case 1:
                DBToast.showText(this,"权限不足,请到设置更改执行方式!",false);
                break;
            case 2:
                String shellCommand = "am force-stop " + packageName;
                ShellUtils.execCommand(shellCommand, true);
                DBToast.showPurpleToast(this,"已终止$"+name+"!");
                 break;
            case 3:
                ShizukuShell.getInstance().exec(new Shell.Command(
                        "am force-stop ", packageName));
                DBToast.showPurpleToast(this,"已终止$"+name+"!");
                break;
        }

        finish();

    }
}
